home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15599 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  71 lines

  1. Path: host1.einstein.com.ar!news
  2. From: jkohen@einstein.com.ar (Javier Kohen)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: HELP: Code in Header Files
  5. Date: Sat, 06 Apr 1996 02:16:36 GMT
  6. Organization: Red Einstein
  7. Message-ID: <4k4pku$pea@host1.einstein.com.ar>
  8. References: <4jakhm$g3d@news.asu.edu>
  9. Reply-To: jkohen@einstein.com.ar
  10. NNTP-Posting-Host: ppp-12.einstein.com.ar
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. ryan1m@imap2.asu.edu wrote:
  14.  
  15.  
  16. >I have a problem understanding how header files work.  If it matters I am 
  17. >using Borland C++ 4.5...
  18.  
  19. >The problem is I defined a header file   string.h  in this I declared a 
  20. >string class.  If I put the actual code to the functions in this class 
  21. >into the header file, the compiler does not like it.  I looked at other 
  22. >.h files and saw they did not do it this way.
  23.  
  24. >So then I tried writing the actual code into string.cpp and compiling 
  25. >that with and #include "string.h".
  26.  
  27. >It worked but my code for my program does not recognize the functions.  
  28. >It says I did not code them yet.
  29.  
  30. You must compile the file with main() and string.cpp together.
  31. ie: (what's exactly ie, sorry but i am a spanish speaker)
  32.  
  33. bcc main.cpp string.cpp
  34.  
  35. If you're using the IDE, use add node option and add the string.cpp
  36. file.
  37.  
  38. >It finds the headers just fine but not the actual code.
  39.  
  40. >ie:
  41.  
  42. >#include "string.h"
  43.  
  44. >void main(void)
  45.  
  46. (void) = () in c++
  47.  
  48. >{
  49. >    String blah("hello world");
  50. >}
  51.  
  52. >the error will say something like
  53.  
  54. >Undefined Symbol String::~String() in module STEST.CPP
  55.  
  56. >and it goes on to list the rest of the function not "defined".
  57.  
  58. >Please help...
  59.  
  60. >Thanks,
  61.  
  62. I could explain you all  about this, Ď„ause i had the same kind of
  63. problems, but looking another people programs, the compiler manuals
  64. and playing with it, i got the idea.
  65.  
  66. >Mike Ryan   ryan1m@asu.edu
  67.  
  68. Javier Kohen jkohen@einstein.com.ar
  69.  
  70.  
  71.